<template>
	<view style="height: 100vh;">
		<!-- #ifdef APP-PLUS -->
		<navBar title="现场视频"></navBar>
		<!-- #endif -->
		<scroll-view scroll-y class="hwq-scroll-box">
			<web-view :src="linkUrl"></web-view>
		</scroll-view>
	</view>
</template>

<script>
import { getToken } from '@/utils/auth'
import { getSystemHeightInfo } from "@/utils/common.js"

export default {
	name: "liveVideo",
	data() {
		return {
			// 外链地址
			linkUrl: '',
		}
	},
	onReady(){
		// #ifdef APP-PLUS
			var height=0;//定义动态的高度变量，如高度为定值，可以直接写
			var width=0;//定义动态的高度变量，如高度为定值，可以直接写
			uni.getSystemInfo({
			//成功获取的回调函数，返回值为系统信息
			success: (sysinfo) => {
			height = sysinfo.windowHeight;//自行修改，自己需要的高度 此处如底部有其他内容，可以直接---(-50)这种
			width = sysinfo.windowWidth;//自行修改，自己需要的高度 此处如底部有其他内容，可以直接---(-50)这种
			console.log(height,width,'宽高')
			},
			complete: () => {
			}
			});
			var currentWebview = this.$scope.$getAppWebview();//获取当前web-view
			setTimeout(function() {
			var wv = currentWebview.children()[0];
			wv.setStyle({//设置web-view距离顶部的距离以及自己的高度，单位为px
			top: 75,//此处是距离顶部的高度，应该是你页面的头部
			height:height,//webview的高度
			width:width,//webview的高度
			scalable:false      //webview的页面是否可以缩放，双指放大缩小
			})
			}, 100);//如页面初始化调用需要写延迟
		// #endif
	},
	onLoad(options) {
		// #ifdef MP-WEIXIN
			this.getWebviewPageTitle()
		// #endif
		let type = 'app'
		// #ifdef MP-WEIXIN
		type = 'wx'
		// #endif
		this.videoType = options.videoType
		const systemInfo = getSystemHeightInfo()
		this.linkUrl = `${this.$config.SHARE_URL}?token=${getToken()}&page=liveVideo&projectId=${uni.getStorageSync("isOwner")}&id=${options.id}`
		// this.linkUrl = `http://192.168.21.155:8800/#/?token=${getToken()}&page=liveVideo&projectId=${uni.getStorageSync("isOwner")}&id=${options.id}&videoType=${0}&time=${Date.now()}`
		this.linkUrl = `${this.$config.SHARE_URL}?token=${getToken()}&page=liveVideo&projectId=${uni.getStorageSync("isOwner")}&type=${type}&systemInfo=${JSON.stringify(systemInfo)}&id=${options.id}&videoType=${options.videoType || 0}}`
		this.linkUrl = `${this.$config.SHARE_URL}?token=${getToken()}&page=liveVideo&projectId=${uni.getStorageSync("isOwner")}&type=${type}&systemInfo=${JSON.stringify(systemInfo)}&id=${options.id}&videoType=${options.videoType || 0}`
		// this.linkUrl = `http://192.168.21.217:8800/#/?token=${getToken()}&page=liveVideo&projectId=${uni.getStorageSync("isOwner")}&type=${type}&systemInfo=${JSON.stringify(systemInfo)}&id=${options.id}&videoType=${options.videoType || 0}&time=${Date.now()}`
		console.log(this.linkUrl, '路径');
	},
	methods: {
		 getWebviewPageTitle() {
			setTimeout(() => {
				uni.setNavigationBarTitle({ title: "现场视频" });
				uni.setNavigationBarTitle({ title: this.videoType === 0 ? "现场视频" : "视频回放" });
			}, 2000);
		},
	}
}
</script>

<style scoped lang="scss">
	.hwq-scroll-box {
		height: calc(100% - 130rpx);
		padding-top: 20rpx;
		box-sizing: border-box;
	}
	
	.hwq-scroll-box.hwq-bot-btn-box {
		height: calc(100% - 250rpx);
	}
	
	.hwq-scroll-box.hwq-is-search {
		height: calc(100% - 200rpx);
	}
	
	.hwq-scroll-box.hwq-bot-btn-box.hwq-is-search {
		height: calc(100% - 320rpx);
	}
</style>